from typing import Union
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from pydantic import BaseModel
import os

app = FastAPI()


@app.get("/")
def read_root():
    content=""
    with open(os.path.join(os.curdir,'index.html'),'r',encoding='utf-8') as file:
        content=file.read()
    return HTMLResponse(content)


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}